package org.example.friend.controller.user;

import org.example.common.core.constants.HttpConstants;
import org.example.common.core.controller.BaseController;
import org.example.common.core.model.Result;
import org.example.common.core.model.TableDataInfo;
import org.example.friend.aspect.CheckUserStatus;
import org.example.friend.model.exam.dto.ExamDTO;
import org.example.friend.model.exam.dto.ExamQueryDTO;
import org.example.friend.service.exam.IExamService;
import org.example.friend.service.user.IUserExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author : [Pashm]
 * @version : [v1.0]
 */
@RestController
@RequestMapping("/user/exam")
public class UserExamController extends BaseController {

    @Autowired
    private IUserExamService userExamService;

    @CheckUserStatus
    @PostMapping("/enter")
    public Result<Void> enter(@RequestHeader(HttpConstants.AUTHENTICATION)String token, @RequestBody ExamDTO examDTO){

        return toResult(userExamService.enter(token, examDTO.getExamId()));
    }
    @GetMapping("/list")
    public TableDataInfo list(ExamQueryDTO examQueryDTO){
        return userExamService.list(examQueryDTO);
    }
}
